package com.elontian.http.async2.impl;

import java.util.Map;

import android.widget.ImageView;

import com.elontian.http.async2.IAsyncHttpRequest;
import com.elontian.http.async2.handler.AsyncHttpHandler;
import com.elontian.http.async2.strategy.IFactory;
import com.elontian.http.async2.strategy.impl.GetStrategyFactory;
import com.elontian.http.async2.strategy.impl.LoadImgStrategyFactory;
import com.elontian.http.async2.strategy.impl.PostStrategyFactory;
import com.elontian.http.async2.util.AsyncRunable;

public class AsyncHttpRequest implements IAsyncHttpRequest {

	@Override
	public void get(final String url, final AsyncHttpHandler handler) {
		// TODO Auto-generated method stub
		handler.setUrl(url);
		IFactory factory = new GetStrategyFactory(url);
		AsyncRunable run = new AsyncRunable(handler);
		run.setStrategy(factory.createStrategy());
		run.excute();
	}

	@Override
	public void post(String url, Map<String, Object> params,
			AsyncHttpHandler handler) {
		// TODO Auto-generated method stub
		handler.setUrl(url);
		IFactory factory = new PostStrategyFactory(params, url);
		AsyncRunable run = new AsyncRunable(handler);
		run.setStrategy(factory.createStrategy());
		run.excute();

	}


}
